<template>
  <div class="view-card">
    <header class="view-header">
      <el-page-header content="查看详情" @back="$router.back()" />
    </header>
    <main class="view-main">
      <div class="form-container">
        <div class="title">车辆信息</div>
        <div class="form">
          <el-form label-width="100px">
            <el-form-item label="车主姓名：">{{ userInfo.personName }}</el-form-item>
            <el-form-item label="联系方式：">{{ userInfo.phoneNumber }}</el-form-item>
            <el-form-item label="车辆号码：">{{ userInfo.carNumber }}</el-form-item>
            <el-form-item label="车辆品牌：">{{ userInfo.carBrand }}</el-form-item>
          </el-form>
        </div>
      </div>
      <div class="table-container">
        <div class="title">月卡缴费记录</div>
        <div class="table">
          <el-table :data="feeList" border style="width: 100%">
            <el-table-column type="index" label="序号" width="50" />
            <el-table-column #default="{ row }" label="有效时间">
              {{ row.cardStartDate }} 至 {{ row.cardEndDate }}
            </el-table-column>
            <el-table-column label="支付金额" width="200" prop="paymentAmount" />
            <el-table-column label="办理时间" prop="createTime" />
            <el-table-column label="办理人" width="100" prop="createUser" />
          </el-table>
        </div>
      </div>
    </main>
  </div>
</template>

<script>
import { getCardAPI } from '@/api/Car/carCard'
export default {
  name: 'ViewCard',
  data() {
    return {
      // 车主详情
      userInfo: [],
      // 支付记录
      feeList: []
    }
  },
  computed: {
    id() {
      return this.$route.params.id
    }
  },
  mounted() {
    this.getCardDetail()
  },
  methods: {
    // 获取月卡详情
    async getCardDetail() {
      const res = await getCardAPI(this.id)
      this.userInfo = res.data
      this.feeList = res.data.rechargeList
    }
  }
}
</script>

<style scoped lang="scss">
.view-card {
  background-color: #f4f6f8;
  height: 100vh;

  .view-header {
    display: flex;
    align-items: center;
    padding: 0 20px;
    height: 64px;
    background-color: #fff;
  }

  .view-main {
    background: #f4f6f8;
    padding: 20px 130px;

    .form-container {
      background-color: #fff;

      .title {
        height: 60px;
        line-height: 60px;
        padding-left: 20px;
      }

      .form {
        margin-bottom: 20px;
        padding: 20px 65px 24px;

        .el-form {
          display: flex;
          flex-wrap: wrap;

          .el-form-item {
            width: 50%;
          }
        }
      }
    }

    .table-container {
       background-color: #fff;
      .title {
        height: 60px;
        line-height: 60px;
        padding-left: 20px;
      }

      .table {
        margin-bottom: 20px;
        padding: 20px 65px 24px;
      }
    }
  }
}
</style>
